草庐IT

node.js - Angular 4 和 SEO

全部标签

javascript - 关于记录 JavaScript : JS types 的问题

考虑到我将来要和一个更大的团队一起工作,我正在尝试自学一些前端语言的基本注释和文档原则。目前我正在研究JS。在大多数情况下,我使用Google'sStyleGuide作为首选,但我还有一些问题。假设我有一个像这样的ajax函数:functioninitFunction(src,wrapper){$.getJSON(src,{format:"json"}).done(function(data){varwrapper=$(wrapper),contents=callAnotherFunction($(data)[0]);//Populatesthewrapperelement.wrapp

javascript - Nightmare Js 评估页面

我使用Nightmare.js运行以下代码:vartest=newNightmare().viewport(1000,1000).useragent("Mozilla/5.0(WindowsNT6.3;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/38.0.2125.111Safari/537.36").goto('https://en.wikipedia.org/wiki/Ubuntu').inject('js','jquery.js').wait(500).screenshot('page.png').evaluate(functi

javascript - 有没有一种方法可以在不渲染任何其他 js 文件的情况下在 Rails Controller 方法中发出警报/弹出窗口

defdelete_usersusers=User.active.where(:id=>params[:users])users.eachdo|user|array=[]ifuser.active?array0)user.update_attributes(:status=>"inactive")else"Iwantanalert/popupheresayingnousers,when'delete_users'iscalledandtheconditioncomeshere."........dootherstuff......endend结束在Controller中,我有这个方法,

javascript - 使用哈希 url 卡在 Angular ui-router State.go 上?

我正在研究ui-router。我有一个状态:.state('new-personal-orders',{url:'/orders/new-personal-orders/:catId?',template:''})在我的Controller中,我可以使用$state.go('new-personal-orders',null,{reload:true})在Html文件中我有一个anchor标记:Link如果标签被点击,状态就会改变,'new-personal-orders'变成当前状态,在url中有尾随散列。然后url看起来像:http://localhost:3000/orders/

javascript - ngFor 中的 Angular2 组件抛出错误(viewFactory 不是函数)

我在Angular2应用程序(测试版1)中有一个ComponentB。在我将它放在ComponentA的ngFor循环中之前,它工作得很好。我收到了一个相当神秘的错误:EXCEPTION:TypeError:viewFactory_ComponentB0isnotafunctionin[numbersinComponentA@1:23]BrowserDomAdapter.logError@angular2.dev.js:22690BrowserDomAdapter.logGroup@angular2.dev.js:22701ExceptionHandler.call@angular2.

javascript - 在 Node.js 中模拟嵌套模块?

我有这些文件:文件1.jsvarmod1=require('mod1');mod1.someFunction()...文件2.jsvarFile1=require('./File1');现在在为File2编写单元测试时,是否可以模拟mod1,这样我就不会调用mod1.someFunction()? 最佳答案 我通常使用mockery模块,如下所示:lib/file1.jsvarmod1=require('./mod1');mod1.someFunction();lib/file2.jsvarfile1=require('./file

javascript - 使用 http.get node.js 的 promise

我正在做nodeschool练习,Thisproblemisthesameasthepreviousproblem(HTTPCOLLECT)inthatyouneedtousehttp.get().However,thistimeyouwillbeprovidedwiththreeURLsasthefirstthreecommand-linearguments.YoumustcollectthecompletecontentprovidedtoyoubyeachoftheURLsandprintittotheconsole(stdout).Youdon'tneedtoprintoutt

javascript - Three.js 将对象添加到组中但保持全局位置/旋转/比例不变

我想将一个对象从一个组(或世界/场景)移动到另一个组,但要保持其全局转换不变。基本上,我不想看到对象发生变化。基本上,是这样的://storecurrentworldtransformationvarorigWorldMatrix=myObject.matrixWorld.clone();//moveobjecttoagroup(thatispositionedandrotatedarbitrarily)someGroup.add(myObject);//restorepreviousworldtransformationmyObject.matrixWorld.copy(origWo

javascript - Hammer.js:如何检测任意数量/多个手指的捏合

当我创建一个新的HammerPinch事件时,没有在选项中提及指针的数量,它最多只能检测到3个手指,如果我提到指针,例如varmultiPinch=newHammer.Pinch({event:'multipinch',pointers:4,threshold:0});,那么它只会检测到4根手指的捏合。我曾尝试在文档和所有地方进行搜索,但无法在一个事件中检测到2、3甚至10个手指的捏合。我需要这个,因为我的网络应用程序必须在81英寸大的屏幕上运行。 最佳答案 我终于解决了!我不知道这是否是黑客攻击,但它确实有效!最后的解决方案非常简

javascript - Angular 使用根作用域与服务来共享数据

我一直在读wroxangularbook.在书中作者描述了一种在Controller之间共享数据的方法是在根范围内拥有一个属性更新根作用域的属性广播属性已更新的事实所有需要知道的子作用域,都会收听广播。而不是在服务上公开一个对象,让Angular的双向数据绑定(bind)完成所有繁重的工作。为什么有人会采用“根范围发布/订阅”方法,而不是在服务上公开对象? 最佳答案 这个问题很有趣。首先我们应该考虑各个层面的差异:范围对于$rootScope,我们在全局范围内定义变量在共享服务的情况下,我们可以将此服务注入(inject)真正使用此